/**
 * Author@ Cheng Feitian
 * Date: 2021-3-31
 * Description: 递减运算符重载
 */

#include <algorithm>
#include <iostream>
#include <string>

using namespace std;
const int maxn = 1024;

class MyInteger{
    friend ostream & operator<<(ostream & cout,MyInteger myInteger);
private:
    int m_Num;

public:
    MyInteger()
    {
        m_Num = 10;
    }

    //前置运算符
    MyInteger & operator--(){
        //先递减
        m_Num--;
        //后返回
        return *this;
    }
    //后置运算符
    MyInteger operator--(int){
        //先 暂存
        MyInteger temp = *this;
        //后 递减
        this->m_Num--;
        //在返回暂存值
        return temp;
    }
};

ostream & operator<<(ostream & cout,MyInteger myInteger){
    cout << myInteger.m_Num;
    return cout;
}

void test01(){
    MyInteger myint;

    cout << --(--myint) << endl;
    cout << myint << endl;
}

void test02(){
    MyInteger myint;

    cout << myint-- << endl;
    cout << myint << endl;
}

int main()
{
    test01();
    test02();
    return 0;
}
